/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Student;

import Academic.AcademicBean;
import Address.AddressBean;
import Admission.AdmissionBean;
import Category.CategoryBean;
import Country.CountryBean;
import Course.CourseBean;
import Documents.DocumentsBean;
import Documents.StudentDocumentBean;
import Facility.FacilityBean;
import Parents.ParentsBean;
import State.StateBean;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Vector;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author mishra
 */
public class StudentProfile extends HttpServlet {

   
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
                String Email=request.getParameter("uid");
                StudentBean sb=Student.Query.viewSpecific(Email);
                if(sb.getStudentId()!=0){
                AdmissionBean adb = sb.getAdmissionBean();
                CourseBean cb = adb.getCourseBean();
                AddressBean ad = sb.getAddressBean();
                CountryBean cob = ad.getCountryBean();
                StateBean stb = ad.getStateBean();
                CategoryBean cab = sb.getCategoryBean();
                ParentsBean pb=adb.getParentsBean();
                AcademicBean acb=adb.getAcademicBean();
                FacilityBean fb=adb.getFacilityBean();
                
            
            out.println("<div class='box-content'><div class='cl'>");
            
            out.println("<div class='pull-left'><h3>User Profile</h3>");                        
            out.println("<div class='control-group'><div class='controls'><ul class='gallery'><li><span class='preview' id='photo1'><img id='"+sb.getPhotoName()+"' style='height: 115px; width: 90px; cursor: -webkit-zoom-in;' title='"+sb.getPhotoName()+"' src='"+Documents.Query.getPhoto(sb.getPhotoName())+"' alt='"+sb.getPhotoName()+"'></span></li></ul></div></div>");                            
            out.println("</div>");                                
            
            out.println("<div class='details pull-left userprofile'>");  
            
            out.println("<table class='table table-striped table-detail'><tbody><tr>");                            
            out.println("<th>Student Name:</th>");                            
            out.println("<td>"+sb.getStudentName()+"</td></tr>");                                
            out.println("<tr><th>Register date:</th>");                                
            out.println("<td>"+adb.getEntryDate()+"</td></tr>");                                
            out.println("<tr><th>Course:</th>");                                
            out.println("<td>"+cb.getCourseName()+"</td></tr>");                                
            out.println("<tr><th>User Type:</th>");           
            out.println("<td><span class='label label-success'>Student</span></td></tr>");                                
            out.println("<tr><th>Email:</th>");                                
            out.println("<td><a href='#'>"+adb.getStudentEmail()+"</a></td></tr>");  
            out.println("<tr><th>Roll Number:</th>");
            out.println("<td>"+adb.getRollNumber()+"</td></tr>"); 
            out.println("</tbody></table></div></div>"); 
                 
            out.println("<h3 class='divide'>Basic information</h3>");                                
            out.println("<table class='table table-striped table-detail'>");                                
            out.println("<tbody><tr>");                                
            out.println("<tr><th>Session:</th>");                                
            out.println("<td>"+adb.getStudentSession()+"</td></tr>"); 
            out.println("<tr><th>Semester:</th>");                                
            out.println("<td>"+adb.getSemester()+"</td></tr>"); 
            out.println("<tr><th>Mobile Number:</th>");                                
            out.println("<td>"+adb.getStudentMobile()+"</td></tr>");                                
            out.println("<tr><th>Gender:</th>");                                
            out.println("<td>"+sb.getGender()+"</td></tr>");                                
            out.println("<tr><th>Category:</th>");                                
            out.println("<td>"+cab.getCategory()+"</td></tr>");                                
            out.println("<tr><th>Application No.:</th>");                                
            out.println("<td>"+adb.getApplicationNo()+"</td></tr>");                                
            out.println("<tr><th>Addmission ID:</th>");                                
            out.println("<td>"+adb.getAddmissionId()+"</td></tr>");                                
            out.println("<tr><th>Date of Birth:</th>");                                
            out.println("<td>"+sb.getDob()+"</td></tr>");                                
            out.println("<tr><th>Address:</th>");                                
            out.println("<td>"+ad.getAddress1()+""+ad.getAddress2()+"</td></tr>");                                
            out.println("<tr><th>Pin Code:</th>");                                
            out.println("<td>"+ad.getPinCode()+"</td></tr>");
            out.println("<tr><th>State:</th>");                                
            out.println("<td>"+stb.getStateName()+"</td></tr>");
            out.println("<tr><th>Country:</th>");                                
            out.println("<td>"+cob.getCountryName()+"</td></tr>");
            out.println("</tbody></table>");

            out.println("<h3 class='divide'>Guardian/Parents Details</h3>");                                
            out.println("<table class='table table-striped table-detail'>");                                
            out.println("<tbody><tr>");                                
            out.println("<tr><th>Father Name:</th>");                                
            out.println("<td>"+pb.getFatherName()+"</td></tr>"); 
            out.println("<tr><th>Father Mobile No.:</th>");                                
            out.println("<td>"+pb.getFatherMobileNo()+"</td></tr>"); 
            out.println("<tr><th>Father Occupation:</th>");                                
            out.println("<td>"+pb.getFatherOccupation()+"</td></tr>");                                
            out.println("<tr><th>Mother Name:</th>");                                
            out.println("<td>"+pb.getMotherName()+"</td></tr>");                                
            out.println("<tr><th>Mother Mobile No.:</th>");                                
            out.println("<td>"+pb.getMotherMobileNo()+"</td></tr>");                                
            out.println("<tr><th>Mother Occupation:</th>");                                
            out.println("<td>"+pb.getMotherOccupation()+"</td></tr>");                                
            out.println("<tr><th>Guardian Name:</th>");                                
            out.println("<td>"+pb.getGuardianName()+"</td></tr>");                                
            out.println("<tr><th>Guardian Mobile NO.:</th>");                                
            out.println("<td>"+pb.getGuardianMobileNo()+"</td></tr>");                                
            out.println("<tr><th>Guardian Occupation:</th>");                                
            out.println("<td>"+pb.getGuardianOccupation()+"</td></tr>");
            out.println("<tr><th>Relation:</th>");                                
            out.println("<td>"+pb.getRelation()+"</td></tr>");
            out.println("</tbody></table>");
            
            
            out.println("<h3 class='divide'>Academic Details</h3>");                                
            out.println("<table class='table table-striped table-detail'>");                                
            out.println("<tbody><tr>");                                
            out.println("<tr><th>High School Name:</th>");                                
            out.println("<td>"+acb.getHighSchool()+"</td></tr>"); 
            out.println("<tr><th>High School Board Name:</th>");                                
            out.println("<td>"+acb.getHighBoardName()+"</td></tr>"); 
            out.println("<tr><th>High School Maximum Marks:</th>");                                
            out.println("<td>"+acb.getHighMaxMarks()+"</td></tr>");                                
            out.println("<tr><th>High School Obtained Marks:</th>");                                
            out.println("<td>"+acb.getHighMarksObtained()+"</td></tr>");                                
            out.println("<tr><th>Intermediate School Name.</th>");                                
            out.println("<td>"+acb.getInterBoardName()+"</td></tr>");                                
            out.println("<tr><th>Intermediate Maximum Marks:</th>");                                
            out.println("<td>"+acb.getInterMaxMarks()+"</td></tr>");                                
            out.println("<tr><th>Intermediate Obtained Marks:</th>");                                
            out.println("<td>"+acb.getInterMarksObtained()+"</td></tr>");                                
            out.println("<tr><th>Other Exame Name:</th>");                                
            out.println("<td>"+acb.getOther()+"</td></tr>");                                
            out.println("<tr><th>Other Exame Board/University/Type:</th>");                                
            out.println("<td>"+acb.getHighBoardName()+"</td></tr>");
            out.println("<tr><th>Other Exam Maximum Marks:</th>");                                
            out.println("<td>"+acb.getOtherMaxMarks()+"</td></tr>");
            out.println("<tr><th>Other Exam Obtained Marks/Rank:</th>");                                
            out.println("<td>"+acb.getOtherMaxMarks()+"</td></tr>");
            out.println("</tbody></table>"); 
            
           
            out.println("<h3 class='divide'>Facility</h3>");                                
            out.println("<table class='table table-striped table-detail'>");                                
            out.println("<tbody><tr>");                                
            out.println("<tr><th>Transport Status:</th>");
            if(fb.getTransportationStatus()==1){
            out.println("<td><span class='label label-success'>Alloted</span></td></tr>");
            }else if(fb.getTransportationStatus()==0){
            out.println("<td><span class='label label-warning'>Not Alloted</span></td></tr>");
            }
            out.println("<tr><th>Hostel Status:</th>");
            if(fb.getHostelStatus()==1){
            out.println("<td><span class='label label-success'>Alloted</span></td></tr>");
            }else if(fb.getHostelStatus()==0){
            out.println("<td><span class='label label-warning'>Not Alloted</span></td></tr>");
            }
            out.println("<tr><th>Mess Status:</th>");  
            if(fb.getMessStatus()==1){
            out.println("<td><span class='label label-success'>Alloted</span></td></tr>");
            }else if(fb.getMessStatus()==0){
            out.println("<td><span class='label label-warning'>Not Alloted</span></td></tr>");
            }
            out.println("</tbody></table>"); 
           
            out.println("<h3 class='divide'>Documents</h3></div>");                                
            //out.println("<legend>Documents</legend>");                                
//            out.println("<table class='table table-striped table-detail'>");                                
//            out.println("<tbody><tr>");                                
             out.println("<div class='box-content'><div class='cl'>");
            DocumentsBean docu=new DocumentsBean();
            Vector<Object> list=Documents.Query.viewSpecificStuAllDocu(adb.getAddmissionId());
                  Iterator it=list.iterator();
                  while(it.hasNext()){
                      StudentDocumentBean sdb= (StudentDocumentBean)it.next();
                      DocumentsBean db=sdb.getDocumentsBean();
                      out.println("<div class='pull'>");                        
                      out.println("<div class='control-group'><div class='controls'><ul class='gallery'><li><span class='preview' id='photo1'><img id='"+sdb.getDocumentName()+"' style='height: 115px; width: 90px; cursor: -webkit-zoom-in;' title='"+sdb.getDocumentName()+"' src='"+Documents.Query.getPhoto(sdb.getDocumentName())+"' alt='"+sdb.getDocumentName()+"'></span></li></ul></div></div>");
                      out.println(db.getDocumentName()+"___");
                      out.println("</div>");  
                  }
//            out.println("</tbody></table></div>");
                  out.println("</div></div>");
            
            }else
            {
               out.println("<tr>");
               out.println("<td colspan='3'>");
               out.println("<b>No Record Found</b>");
               out.println("</td>");
               out.println("</tr>");
            }
            }catch(Exception e){
            out.println(e);
        }  finally {
            out.close();
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Handles the HTTP <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}
